package com.hooker.plugins.bytedance;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;

import com.hooker.base.BaseXposedLoader;

import java.util.ArrayList;
import java.util.List;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class AdHookerEntry extends BaseXposedLoader {

    static List<String> packList = new ArrayList<>();

    static {
        packList.add("com.hold.colorboard");
    }

    String str = "308202bf308201a7a00302010202043f847caa300d06092a864886f70d01010b05003010310e300c060355040a1305636f6c6f72301e170d3230303332353033353730395a170d3435303331393033353730395a3010310e300c060355040a1305636f6c6f7230820122300d06092a864886f70d01010105000382010f003082010a0282010100b5d0dac5d356069a841873325d443528231fcc0cba49900ca52db41b382b4edeb512f7e7dd2a07fcad2a79194efa1f2841d22fb6793893e22d5f0aed24644b88651049de6f312187caa78198229e2541ee6c2cba2c08815d254de932d954e94243dba68128d59dc57156328c8bdcbb2bfd68428ad9e871927838d1a1d34c44df4dc55764af147a01483c2dcfb193278d9503408ef1ba456eb7368e1d0886340d1e4f384a8a941074c9762986567e64281262085ebfa7f5664f83a04acfe0888eca80a2d74ded6d1ef6256bbb39c9cdcf1b7cedc4f1d8e0bdd0782b54909e2f987271f20d22fa7e1d5c4776b38f49027f23eefbf8daa4b80851242955910a21150203010001a321301f301d0603551d0e0416041454ee68c32d9a7bab38e5e109209d280921e68bd7300d06092a864886f70d01010b0500038201010057e16929f1669472754f514b7f9f87291e5df73729b36a86374be307852f0a6cf8c581903b035b442f57b19229e79308e9631fc33646ff8b841576d74bdc2e1419f98c7a9497312df36ab9a72d071c1e1fa9afea04bdf86d7875b7823d8d0184a3e5ba118aeb480cf070b75e267ddaf1ddb70b69de46774128d8da613d1412a17be2b22e68673675d7e1516f90628879692e1f1438da60ad612d8d3104d5d7ff30cd6688c926b7b62758985e373bd8580cd6f1b64fe7b46421b0e1ad3417d96f9d5a843180ed74f003c377b03e40e51b56a301e61249e2b6e1235ab985f8c6db984c09150a7a9542afccc7bd2636f104768100732a70a6b50fad989aaac65cd6";

    public AdHookerEntry(Context context, XC_LoadPackage.LoadPackageParam loadParams) {
        super(context, loadParams);
    }

    @Override
    public void hook(Object... calls) {
        String className = "com.bytedance.sdk.openadsdk.core.v";

        hookMethod(className, "loadFullScreenVideoAd", "com.bytedance.sdk.openadsdk.AdSlot", "com.bytedance.sdk.openadsdk.TTAdNative$FullScreenVideoAdListener", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                Object o = param.args[1];
                log("bytedance.ad.listener = " + o);

                hookMethod(o.getClass(), "onFullScreenVideoAdLoad", "com.bytedance.sdk.openadsdk.TTFullScreenVideoAd", new XC_MethodHook() {
                    @Override
                    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                        Object ad = param.args[0];
                        log("bytedance.ad.info = " + ad);

                    }
                });

            }
        });
    }
}
